package com.example.demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 18:03 2020/9/27
 * @Modified By:
 */
public class MyInvocationHandler implements InvocationHandler {
    private ProxiedService service;

    public MyInvocationHandler(ProxiedService service) {
        this.service = service;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        // System.out.println(getClass().getCanonicalName() + "." + getClass().getMethod("invoke", Object.class, Method.class, Object[].class));
        System.out.println("invoke()被调用了！");
        return method.invoke(service, args);
    }
}
